From bec755ea3c0ef2b1002720aa07373b5e459b8994 Mon Sep 17 00:00:00 2001 From: "kfraser@localhost.localdomain" Date: Thu, 25 Jan 2007 12:30:25 +0000 Subject: [PATCH] During suspend, return immediately with a failure if the domain will never suspend, instead of pointlessly retrying. Signed-off-by: John Levon --- tools/libxc/xc_linux_save.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/tools/libxc/xc_linux_save.c b/tools/libxc/xc_linux_save.c index 41a38a0976..e6c1799d7c 100644 --- a/tools/libxc/xc_linux_save.c +++ b/tools/libxc/xc_linux_save.c @@ -379,8 +379,29 @@ static int suspend_and_state(int (*suspend)(int), int xc_handle, int io_fd, ERROR("Could not get vcpu context"); - if (info->shutdown && info->shutdown_reason == SHUTDOWN_suspend) - return 0; // success + if (info->dying) { + ERROR("domain is dying"); + return -1; + } + + if (info->crashed) { + ERROR("domain has crashed"); + return -1; + } + + if (info->shutdown) { + switch (info->shutdown_reason) { + case SHUTDOWN_poweroff: + case SHUTDOWN_reboot: + ERROR("domain has shut down"); + return -1; + case SHUTDOWN_suspend: + return 0; + case SHUTDOWN_crash: + ERROR("domain has crashed"); + return -1; + } + } if (info->paused) { // try unpausing domain, wait, and retest @@ -394,7 +415,7 @@ static int suspend_and_state(int (*suspend)(int), int xc_handle, int io_fd, if( ++i < 100 ) { - ERROR("Retry suspend domain."); + ERROR("Retry suspend domain"); usleep(10000); // 10ms goto retry; } -- 2.30.2